package com.im.netty.protocol;

import com.alibaba.fastjson.JSON;

public class JSONSerializer implements Serializer {

	@Override
	public byte getSerializerAlgorithm() {
		return SerializerAlgorithm.JSON;
	}

	@Override
	public byte[] serializer(Object object) {
		return JSON.toJSONBytes(object);
	}

	@Override
	public <T> T deserializer(Class<T> clazz, byte[] bytes) {
		return JSON.parseObject(bytes, clazz);
	}

}
